package net.learn.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.learn.framework.common.page.PageResult;
import net.learn.framework.common.utils.Result;
import net.learn.system.query.SysFillQuery;
import net.learn.system.query.SysJudgeQuery;
import net.learn.system.service.SysFillService;
import net.learn.system.service.SysJudgeService;
import net.learn.system.vo.SysFillVO;
import net.learn.system.vo.SysJudgeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 填空管理
 */
@RestController
@RequestMapping("sys/fill")
@Tag(name="判断管理")
@AllArgsConstructor
public class SysFillController {

    @Autowired
    private final SysFillService fillService;

    @GetMapping("getFill")
    @Operation(summary = "分页获取判断题列表")
    public Result<PageResult<SysFillVO>> getFill(@Valid SysFillQuery query){
        PageResult<SysFillVO> page = fillService.qryFillListPage(query);

        return Result.ok(page);
    }
    @PostMapping("getFillList")
    @Operation(summary = "获取填空列表")
    public Result<List<SysFillVO>> getFillList(@RequestBody SysFillQuery query){
        List<SysFillVO> list = fillService.qryFillList();

        return Result.ok(list);
    }
    @PostMapping("getFillRandList")
    @Operation(summary = "获取随机填空题")
    public Result<List<SysFillVO>> getFillRandList(@RequestBody SysFillQuery query){
        List<SysFillVO> list = fillService.qryFillRandList(query);

        return Result.ok(list);
    }
    @PostMapping("getPaperFillList")
    @Operation(summary = "获取试卷题库列表")
    public Result<List<SysFillVO>> getPaperFillList(@RequestBody SysFillQuery query){
        List<SysFillVO> list = fillService.qryPaperFillList(query);

        return Result.ok(list);
    }
    @PostMapping("getPaperFillCondition")
    @Operation(summary = "获取正在考试试卷题库列表")
    public Result<List<SysFillVO>> getPaperFillCondition(@RequestBody SysFillQuery query){
        List<SysFillVO> list = fillService.qryPaperFillCondition(query);

        return Result.ok(list);
    }
    @PostMapping("/updateFill")
    @Operation(summary = "修改填空")
    public Result<String> updateFill(@RequestBody @Valid SysFillVO vo){
        fillService.updateFill(vo);

        return Result.ok();
    }
    @PostMapping("save")
    @Operation(summary = "新增填空")
    public Result<String> save(@RequestBody SysFillVO vo){
        fillService.addFill(vo);

        return Result.ok();
    }

    @DeleteMapping
    @Operation(summary = "删除")
    public Result<String> deleteById(@RequestBody List<Long> idList){

        fillService.delete(idList);
        return Result.ok();
    }
}

